<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
window.onload = function() {
	var reg = document.getElementById("reg");
	var ser = document.getElementById("ser");
	reg.onmouseover = function() {
		reg.style.cursor = "pointer";
	};
	ser.onmouseover = function() {
		ser.style.cursor = "pointer";
	};
};
</script>


<h2>Notice</h2>
<div id="notice_main_search">
	<form id="query" action="notice.do" method="post">
		<input type="hidden" name="pg" value="1" /> <select name="field">
			<option value="title">제목</option>
			<option value="content">내용</option>
		</select> <input type="text" name="query" value="${ query }" />&nbsp;
		<input type="submit" value="검색" id="ser" class="notice_button" />&nbsp;&nbsp; |&nbsp;&nbsp;
		<c:if test="${ member.mPage == url }"><input type="button" id="reg" value="글쓰기" class="notice_button"></input></c:if>
	</form>
</div>
	
<table class="table">
	<thead>
		<tr>
			<td>등록일</td>
			<td>제목</td>
			<td>조회수</td>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="n" items="${ list }">
			<c:choose>
				<c:when test="${ n.num%2 == 0 }">
					<tr class="odd">
				</c:when>
				<c:otherwise>
					<tr>
				</c:otherwise>
			</c:choose>

			<td>${ n.regdate }</td>
			<c:choose>
				<c:when test="${ n.title.length() < 20 }">
					<td><a href="noticeDetail.do?p=2&url=${url}&seq=${ n.seq }">${ n.title }</a></td>
				</c:when>
				<c:otherwise>
					<td><a href="noticeDetail.do?p=2&url=${url}&seq=${ n.seq }">${ n.title.substring(0, 20).concat("...") }</a></td>
				</c:otherwise>
			</c:choose>
			<td>${ n.hitcount }</td>
			</tr>
		</c:forEach>

	</tbody>
</table>

<div id="searcher">
	<div id="pgselector">
		<c:forEach var="i" begin="1" end="${ count }">
			<a href="notice.do?pg=${ i }">&nbsp;${ i }&nbsp;</a>
		</c:forEach>
	</div>
</div>